package com.example.takeaway.serivce.impl;

import java.util.List;

import com.example.takeaway.entity.Goods;
import com.example.takeaway.entity.Merchant;
import com.example.takeaway.mapper.MerchantMapper;
import com.example.takeaway.serivce.IMerchantService;
import com.example.takeaway.utils.PageResult;
import com.example.takeaway.utils.PageUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * merchantService业务层处理
 * 
 * @author ruoyi
 * @date 2025-05-15
 */
@Service
public class MerchantServiceImpl implements IMerchantService
{
    @Autowired
    private MerchantMapper merchantMapper;

    /**
     * 查询merchant
     * 
     * @param merchantid merchant主键
     * @return merchant
     */
    @Override
    public Merchant selectMerchantByMerchantid(Long merchantid)
    {
        return merchantMapper.selectMerchantByMerchantid(merchantid);
    }

    /**
     * 查询merchant列表
     * 
     * @param merchant merchant
     * @return merchant
     */
    @Override
    public PageResult selectMerchantList(Merchant merchant,int pageNum,int pageSize)
    {


        PageHelper.startPage(pageNum,pageSize);
        List<Merchant> list = merchantMapper.selectMerchantList(merchant);
        PageInfo<Merchant> pageInfo = new PageInfo<>(list);
        PageResult pageResult = PageUtils.getPageResult(pageInfo);
        return pageResult;
    }

    @Override
    public PageResult search(String search, int pageNum, int pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Merchant> list = merchantMapper.search(search);
        PageInfo<Merchant> pageInfo = new PageInfo<>(list);
        PageResult pageResult = PageUtils.getPageResult(pageInfo);
        return pageResult;
    }

    @Override
    public List<Merchant> getMerGoodsList(Merchant merchant) {
        return  merchantMapper.getMerGoodsList(merchant);
    }

    /**
     * 新增merchant
     * 
     * @param merchant merchant
     * @return 结果
     */
    @Override
    public int insertMerchant(Merchant merchant)
    {
        return merchantMapper.insertMerchant(merchant);
    }

    /**
     * 修改merchant
     * 
     * @param merchant merchant
     * @return 结果
     */
    @Override
    public int updateMerchant(Merchant merchant)
    {
        return merchantMapper.updateMerchant(merchant);
    }

    /**
     * 批量删除merchant
     * 
     * @param merchantids 需要删除的merchant主键
     * @return 结果
     */
    @Override
    public int deleteMerchantByMerchantids(Long[] merchantids)
    {
        return merchantMapper.deleteMerchantByMerchantids(merchantids);
    }

    /**
     * 删除merchant信息
     * 
     * @param merchantid merchant主键
     * @return 结果
     */
    @Override
    public int deleteMerchantByMerchantid(Long merchantid)
    {
        return merchantMapper.deleteMerchantByMerchantid(merchantid);
    }
}
